package com.lzm.ydpt.module.mall.activity;

import android.view.View;
import android.widget.ImageView;

import com.byt.framlib.base.BaseActivity;
import com.byt.framlib.commonwidget.ClearableEditText;
import com.byt.framlib.commonwidget.NormalTitleBar;
import com.byt.framlib.commonwidget.OnNoDoubleClickListener;
import com.lzm.ydpt.R;
import com.lzm.ydpt.entity.AddressBook;
import com.lzm.ydpt.module.common.MapAddressActivity;
import com.lzm.ydpt.mvp.contract.MallAddEdtAddressContract;
import com.lzm.ydpt.mvp.presenterimpl.MallAddEdtAddressPresenterImpl;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * 商城添加和编辑地址
 */
public class MallAddEdtAddressActivity extends BaseActivity<MallAddEdtAddressPresenterImpl> implements MallAddEdtAddressContract.View {
    public static final String INP_ADD_EDT_ADDRESS = "ADD_EDT_ADDRESS";
    @BindView(R.id.ntb_mall_add_edt)
    NormalTitleBar ntb_mall_add_edt;
    @BindView(R.id.edt_reciv_user_name)
    ClearableEditText edt_reciv_user_name;
    @BindView(R.id.edt_reciv_user_phone)
    ClearableEditText edt_reciv_user_phone;
    @BindView(R.id.edt_reciv_user_country_name)
    ClearableEditText edt_reciv_user_country_name;
    @BindView(R.id.edt_reciv_user_detail_address)
    ClearableEditText edt_reciv_user_detail_address;
    @BindView(R.id.img_select_default_data)
    ImageView img_select_default_data;

    @Override
    public int getLayoutId() {
        return R.layout.activity_mall_add_edt;
    }

    @Override
    public MallAddEdtAddressPresenterImpl initPreData() {
        return new MallAddEdtAddressPresenterImpl(this);
    }

    @Override
    public void initView() {
        AddressBook addressBook = getIntent().getParcelableExtra(INP_ADD_EDT_ADDRESS);
        ntb_mall_add_edt.setTitleText(addressBook != null ? "编辑地址" : "添加地址");
        ntb_mall_add_edt.setOnBackListener(new OnNoDoubleClickListener() {
            @Override
            protected void onNoDoubleClick(View v) {
                finish();
            }
        });

    }

    @Override
    public void onMallAddEdtAddress() {

    }

    @OnClick({R.id.img_show_local, R.id.ll_select_default_title})
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.img_show_local:
                openActivity(MapAddressActivity.class);
                break;
            case R.id.ll_select_default_title:
                img_select_default_data.setSelected(img_select_default_data.isSelected());
                break;
        }
    }

    @Override
    public void showMessage(String message, String method) {

    }

    @Override
    public void showErrorView(String msg) {

    }
}
